package com.kgc.controller;

import com.github.pagehelper.PageInfo;
import com.kgc.pojo.EbookEntry;
import com.kgc.service.SelectAllService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
@RequestMapping("/sale")
public class ListContorller {

    //引人service层
    @Autowired
    private SelectAllService selectAllService;

    @RequestMapping("/list")
    public String list(Model model, @RequestParam(required = false,defaultValue = "0") Integer categoryId,
                       @RequestParam(required = false,defaultValue = "1")Integer pageNo){

        //调
        PageInfo<EbookEntry> pageInfo = selectAllService.selectEbookEntryById(categoryId, pageNo, 3);

        //存
        model.addAttribute("categoryId",categoryId);
        model.addAttribute("pageNo",pageNo);
        model.addAttribute("pageInfo",pageInfo);

        return "infolist";
    }
}
